package rmi.billing.domain;

import java.io.Serializable;
import java.util.ArrayList;

/*
 * stores all created pricesteps in an ArrayList as PriceStep objects
 */
public class PriceSteps implements Serializable {
	private static final long serialVersionUID = -7498405118358413270L;
	
	private ArrayList<PriceStep> steps = new ArrayList<PriceStep>();

	public PriceSteps() {
		
	}

	public ArrayList<PriceStep> getSteps() {
		return steps;
	}

	public void setSteps(ArrayList<PriceStep> steps) {
		this.steps = steps;
	}
	
	public void addPriceStep(PriceStep ps){
		steps.add(ps);
	
	}
	//returns true if the list contained the specified element
	public boolean removePriceStep(PriceStep ps){ 
		return steps.remove(ps);
	}
	//returns a pricestep with the given start and end price
	public PriceStep getPriceStep(double startPrice, double endPrice){
		
		for(PriceStep ps : steps){
			if (ps.getStartPrice()==startPrice && ps.getEndPrice()==endPrice){
				return ps;
			}
		}
		return null;
	}
}
